package com.example.prayertracker;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.view.Menu;
import android.widget.TextView;

public class Maghrib extends Activity implements SensorEventListener {
	private final int RAKAT_NO = 3;
	TextView proxText;
	TextView counts;
	SensorManager sm;
	Sensor proxSensor;
	int count = 0;

	Intent intent = getIntent();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_maghrib);

		sm = (SensorManager) getSystemService(SENSOR_SERVICE);
		proxSensor = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY);
		proxText = (TextView) findViewById(R.id.textView1);
		counts = (TextView) findViewById(R.id.textView3);

		sm.registerListener(this, proxSensor, SensorManager.SENSOR_DELAY_NORMAL);

	}

	@Override
	public void onAccuracyChanged(Sensor sensor, int accuracy) {

	}

	@Override
	public void onSensorChanged(SensorEvent event) {
		proxText.setText(String.valueOf(event.values[0]));
		if(event.values[0] == 0.0){
			count++;
			if(count <= RAKAT_NO){
				counts.setText(String.valueOf(count));
			}
			else{

				counts.setText("over praying! " + String.valueOf(count) );
			}

		}
	}

}
